﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Guru.Data;

public partial class FE_ChangeRoomModal : HSMPage
{
    protected int RoomID
    {
        get
        {
            return int.Parse(SecureQueryString["roomID"]);
        }
    }
    protected int InvoiceID
    {
        get
        {
            return int.Parse(SecureQueryString["InvoiceID"]);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.PageType = GuruPageType.Modal;
        this.FixedModalWidth = HSMConstants.DefaultFixedModalWidth;
        if (!IsPostBack)
        {
            this.uxCustomerView.LoadByGuestByInvoice(this.InvoiceID);
            this.LoadRooms();
        }
    }

    protected void uxChange_Click(object sender, EventArgs e)
    {
        if (this.uxDiagrams.SelectedRooms.Count <= 0) return;
        int selectedRoomID = int.Parse(this.uxDiagrams.SelectedRooms[0]);
        GuruParameterCollection parameters = new GuruParameterCollection();
        GuruParameterCollection outParameters = new GuruParameterCollection();
        parameters.AddUserLoggedParams();
        parameters.Add("@InvoiceID", this.InvoiceID, DbType.Int32);
        parameters.Add("@FromRoomID", this.RoomID, DbType.Int32);
        parameters.Add("@ToRoomID", selectedRoomID, DbType.Int32);
        HSMCommon.HSMBusiness.UpdateData("spa_HSM_Invoice_ChangeRoom", parameters, out outParameters);
        this.CloseModal(1, "parent.ReloadPage();");
    }

    protected void LoadRooms()
    {
        GuruParameterCollection parameters = new GuruParameterCollection();
        parameters.AddUserLoggedParams();
        parameters.Add("@ViewDate", HSMSessionManager.HotelFilterOptions.ViewDate, DbType.Date);
        parameters.Add("@RoomStatus", HSMEnums.RoomStatus.Empty, DbType.Int32);
        DataTable rooms = HSMCommon.HSMBusiness.GetDataTable("spa_HSM_Room_GetFromDeskDiagram", parameters);
        this.uxDiagrams.RoomList = rooms;
        this.uxDiagrams.DataBind();
    }
}
